package com.smh.demo1.a39;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author shiminghui
 * @date 2025/5/9 20:54
 * @description: TODO
 */
@Component
public class Bean1 implements InitializingBean {
    protected boolean flag;
    protected String initialValue;

    @Autowired
    private Bean2 bean2;

    static void m2() {
        System.out.println("m2");
    }

    @PostConstruct
    public void init() {
        flag = true;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        this.initialValue = "initialValue";
    }

    @Override
    public String toString() {
        return "Bean1{" +
                "flag=" + flag +
                ", initialValue='" + initialValue + '\'' +
                ", bean2=" + bean2 +
                '}';
    }

    public boolean isFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public String getInitialValue() {
        return initialValue;
    }

    public void setInitialValue(String initialValue) {
        this.initialValue = initialValue;
    }

    public Bean2 getBean2() {
        return bean2;
    }

    public void setBean2(Bean2 bean2) {
        this.bean2 = bean2;
    }

    public void m1() {
        System.out.println("m1");
    }

    final void m3() {
        System.out.println("m3");
    }

    private void m4() {
        System.out.println("m4");
    }
}
